//
//  WH_HomeDetailCell.m
//  App_6.23
//
//  Created by wanghao on 16/7/11.
//  Copyright © 2016年 lushan. All rights reserved.
//

#import "WH_HomeDetailCell.h"
#import "WH_Home.h"

@interface WH_HomeDetailCell ()

@property (nonatomic, strong) UIImageView *userAvatar;
@property (nonatomic, strong) UILabel *userName;
@property (nonatomic, strong) UILabel *userIP;
@property (nonatomic, strong) UILabel *userID;
@property (nonatomic, strong) UILabel *orderCount;

@end

@implementation WH_HomeDetailCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1];
        [self createSubs];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
    
}

-(void)createSubs{
    
    self.userAvatar = [UIImageView new];
    self.userAvatar.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:_userAvatar];
    _userAvatar.layer.cornerRadius = 15;
    _userAvatar.layer.masksToBounds = YES;
    [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.equalTo(@10);
        make.bottom.equalTo(@-10);
        make.width.equalTo(self.contentView.mas_height).offset(-20);
    }];
    
    self.userName = [UILabel new];
    _userName.font = [UIFont systemFontOfSize:10.f];
    [self.contentView addSubview:_userName];
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.userAvatar.mas_right).offset(10);
        make.right.mas_equalTo(@-10);
        make.top.equalTo(self.userAvatar);
        make.height.equalTo(self.userAvatar.mas_height).multipliedBy(.5);
        
    }];
    
    self.orderCount = [UILabel new];
    _orderCount.font = [UIFont systemFontOfSize:10.f];
    [self.contentView addSubview:_orderCount];
    [self.orderCount mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.height.equalTo(self.userName);
        make.top.equalTo(self.userName.mas_bottom);
    }];
}

-(void)setRecord:(WH_Home *)record{
    
    if (_record != record) {
        
        _record = record;
    }
    
    [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:self.record.user_avatar] placeholderImage:PLACEHOLDER_CELL_SAME];
    self.userName.text = [NSString stringWithFormat:@"%@(%@)",self.record.user_name,self.record.user_ip];
    self.orderCount.text = [NSString stringWithFormat:@"参与了%@人次 %@",self.record.order_count,self.record.order_time];
    [WH_AppTools changeColor:self.orderCount.text color:[UIColor redColor]  xx:self.record.order_count nn:self.orderCount];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
